package com.hundunjiang.ToolsServer.controller;

import com.hundunjiang.CommonServer.api.CommonResult;
import com.hundunjiang.CommonServer.api.ResultCode;
import com.hundunjiang.ToolsServer.server.EmailService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


@RestController
@Api(tags = "邮件管理")
@RequestMapping("/email")
public class EmailController {

    @Autowired
    private EmailService emailService;

    @ApiOperation("邮箱注册")
    @RequestMapping(path = "/regist",method = RequestMethod.GET)
    @ResponseBody
    public CommonResult regist(
            @ApiParam(name = "email",value = "邮箱") @RequestParam("email") String email,
            @ApiParam(name = "password",value = "密码") @RequestParam("password") String password
    ){
        try{
            emailService.regist(email,password);
            return CommonResult.success(ResultCode.SUCCESS);
        }catch (Exception e){
            e.printStackTrace();
            return CommonResult.failed();
        }
    }
}
